Imports System
Imports System.Web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports DotNetNuke
Namespace NVPortal.Modules.NVNews

    Public MustInherit Class NoImageCustomeDisplay
        Inherits Entities.Modules.PortalModuleBase

#Region "Controls"
#End Region

#Region "Event Handlers"
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Try
                If Not IsPostBack Then

                    Dim DisplayNumber As String
                    If Settings("NVNewsDisplayNumberSetting") <> "" Then
                        DisplayNumber = Settings("NVNewsDisplayNumberSetting")
                    Else
                        DisplayNumber = "1 1" ' 1 row and 1 col
                    End If
                    Dim iDisplay As Integer = 1
                    iDisplay = Split(DisplayNumber)(0) * Split(DisplayNumber)(1)
                    Me.drgOtherNews.RepeatColumns = Split(DisplayNumber)(1)
                    'Cac tin khac cung chuyen muc voi tin nay
                    Dim ds As ArrayList
                    Dim ctlNews As New NV_NewsController
                    ds = ctlNews.selectCustomeNews(IIf(Settings("NVNewsCategorySetting") <> "", Settings("NVNewsCategorySetting"), 0), PortalId, iDisplay)
                    Me.drgOtherNews.DataSource = ds
                    Me.drgOtherNews.DataBind()
                    Me.hplMore.NavigateUrl = CatURL("catid")
                End If
            Catch ex As Exception
                'Me.imgNews.Visible = False
                ' Exception
                ProcessModuleLoadException(Me, ex)
            End Try
        End Sub
        Public Function FormatURL(ByVal sitem As String, ByVal strID As String, ByVal scat As String, ByVal strCatID As String) As String
            Dim i As Integer
            If IsNumeric(Settings("NVNewsDisplayPageSetting")) Then
                i = Settings("NVNewsDisplayPageSetting")
                Return NavigateURL(i) & "&" & scat & "=" & strCatID & "&" & sitem & "=" & strID
            Else
                Return NavigateURL() & "&" & scat & "=" & strCatID & "&" & sitem & "=" & strID
            End If
        End Function
#End Region

#Region "Optional Interfaces"

#End Region
        Protected Sub drgOtherNews_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.DataListItemEventArgs) Handles drgOtherNews.ItemDataBound
            If e.Item.ItemType = ListItemType.Item Or e.Item.ItemType = ListItemType.AlternatingItem Then
                If e.Item.ItemIndex = CType(drgOtherNews.DataSource, ArrayList).Count - 1 Then
                    Try
                        'CType(e.Item.FindControl("hplOtherNews"), HyperLink).Font.Bold = True
                        CType(e.Item.FindControl("bottom_td"), HtmlTableCell).Visible = False
                    Catch ex As Exception

                    End Try
                End If
            End If
            Dim obj As NV_NewsInfo
            obj = New NV_NewsController().GetByID(drgOtherNews.DataKeys(e.Item.ItemIndex))
            Dim ImgNews2 As Image
            ImgNews2 = CType(e.Item.FindControl("ImageHOT"), Image)
            If obj.Createdate() >= Now.Date.AddDays(-1) Then
                ImgNews2.Visible = True
            Else
                ImgNews2.Visible = False
            End If
        End Sub
        Public Function CatURL(ByVal scat As String) As String
            Dim i As Integer
            If IsNumeric(Settings("NVNewsDisplayPageSetting")) Then
                i = Settings("NVNewsDisplayPageSetting")
                Return NavigateURL(i) & "&" & scat & "=" & IIf(Settings("NVNewsCategorySetting") <> "", Settings("NVNewsCategorySetting"), 0)
            Else
                Return NavigateURL() & "&" & scat & "=" & IIf(Settings("NVNewsCategorySetting") <> "", Settings("NVNewsCategorySetting"), 0)
            End If
        End Function
    End Class

End Namespace
